package com.xiao.sulinguser.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiao.sulingpublic.utils.PageUtils;
import com.xiao.sulingpublic.utils.Query;
import com.xiao.sulinguser.dao.MemberDao;
import com.xiao.sulinguser.entity.MemberEntity;
import com.xiao.sulinguser.service.MemberService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("memberService")
public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> implements MemberService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<MemberEntity> page = this.page(
                new Query<MemberEntity>().getPage(params),
                new QueryWrapper<MemberEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public MemberEntity selectUser(Long moblie, String userName) {
        QueryWrapper<MemberEntity> wrapper = new QueryWrapper<MemberEntity>();
        wrapper.eq("mobile",moblie).or().eq("username",userName);

        return baseMapper.selectOne(wrapper);
    }

}